﻿/**
 ** @作者:	   王桂龙 QQ731513122
 ** @日期:	   2019.12.6
 ** @简介:     MenuStrip      
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace BHXJDOTNET.OLD
{
    public partial class BHXJMenuStrip : MenuStrip,IBHXJZOOM
    {
        #region 继承于ZOOM接口的属性和方法
        private Point _OriginPoint = new Point(0, 0);
        [Description("原点(慎用,在足够了解BHXJZoom的情况下使用)"), Category("BHXJZoom")]
        /// <summary>
        /// 原点
        /// </summary>
        public Point OriginPoint
        {
            get
            { return this._OriginPoint; }
            set
            {
                if (this._OriginPoint != value)
                {
                    this._OriginPoint = value;
                    if (DesignMode)
                        this.IniLocation = this.BHXJGetIniLocationInDesignMode();
                }
            }
        }
        private bool _AutoOrigin = false;
        [Description("自动更改原点模式(只在设计模式下有用)"), Category("BHXJZoom")]
        /// <summary>
        /// 自动更改原点模式(只在设计模式下有用)
        /// </summary>
        public bool AutoOrigin
        {
            get
            {
                return this._AutoOrigin;
            }
            set
            {
                if (this._AutoOrigin != value)
                {
                    this._AutoOrigin = value;
                    if (DesignMode)
                    {
                        if (this.AutoOrigin)
                        {
                            this.OriginPoint = this.Location;
                        }
                        else
                        {
                            this.OriginPoint = new Point(0, 0);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 初始尺寸
        /// </summary>
        [Browsable(false)]
        public Size IniSize { get; set; }
        /// <summary>
        /// 初始位置
        /// </summary>
        [Browsable(false)]
        public Point IniLocation { get; set; }
        /// <summary>
        /// 初始字体
        /// </summary>
        [Browsable(false)]
        public Font IniFont { get; set; }

        #endregion



        [Description("菜单字体颜色"), Category("BHXJ")]
        /// <summary>
        /// 菜单字体颜色
        /// </summary>
        public Color FontColor
        {
            get { return this.bhxjrenderer.FontColor; }
            set { this.bhxjrenderer.FontColor = value; this.Invalidate(); }
        }

        [Description("下拉菜单坐标图标区域开始颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉菜单坐标图标区域开始颜色
        /// </summary>
        public Color MarginStartColor
        {
            get { return this.bhxjrenderer.MarginStartColor; }
            set { this.bhxjrenderer.MarginStartColor = value; this.Invalidate(); }
        }

        [Description("下拉菜单坐标图标区域结束颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉菜单坐标图标区域结束颜色
        /// </summary>
        public Color MarginStopColor
        {
            get { return this.bhxjrenderer.MarginStopColor; }
            set { this.bhxjrenderer.MarginStopColor = value; this.Invalidate(); }
        }

        [Description("下拉项背景颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉项背景颜色
        /// </summary>
        public Color DropDownItemBackColor
        {
            get { return this.bhxjrenderer.DropDownItemBackColor; }
            set { this.bhxjrenderer.DropDownItemBackColor = value; this.Invalidate(); }
        }

        [Description("下拉项选中时开始颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉项选中时开始颜色
        /// </summary>
        public Color DropDownItemStartColor
        {
            get { return this.bhxjrenderer.DropDownItemStartColor; }
            set { this.bhxjrenderer.DropDownItemStartColor = value; this.Invalidate(); }
        }

        [Description("下拉项选中时结束颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉项选中时结束颜色
        /// </summary>
        public Color DropDownItemStopColor
        {
            get { return this.bhxjrenderer.DropDownItemStopColor; }
            set { this.bhxjrenderer.DropDownItemStopColor = value; this.Invalidate(); }
        }

        [Description("主菜单项选中时的开始颜色"), Category("BHXJ")]
        /// <summary>
        /// 主菜单项选中时的开始颜色
        /// </summary>
        public Color MenuItemStartColor
        {
            get { return this.bhxjrenderer.MenuItemStartColor; }
            set { this.bhxjrenderer.MenuItemStartColor = value; this.Invalidate(); }
        }

        [Description("主菜单项选中时的结束颜色"), Category("BHXJ")]
        /// <summary>
        /// 主菜单项选中时的结束颜色
        /// </summary>
        public Color MenuItemStopColor
        {
            get { return this.bhxjrenderer.MenuItemStopColor; }
            set { this.bhxjrenderer.MenuItemStopColor = value; this.Invalidate(); }
        }

        [Description("分割线颜色"), Category("BHXJ")]
        /// <summary>
        /// 分割线颜色
        /// </summary>
        public Color SeparatorColor
        {
            get { return this.bhxjrenderer.SeparatorColor; }
            set { this.bhxjrenderer.SeparatorColor = value; this.Invalidate(); }
        }

       
        [Description("主菜单背景开始颜色"), Category("BHXJ")]
        /// <summary>
        /// 主菜单背景开始颜色
        /// </summary>
        public Color MainMenuStartColor
        {
            get { return this.bhxjrenderer.MainMenuStartColor; }
            set { this.bhxjrenderer.MainMenuStartColor = value; this.Invalidate(); }
        }

        [Description("主菜单背景结束颜色"), Category("BHXJ")]
        /// <summary>
        /// 主菜单背景结束颜色
        /// </summary>
        public Color MainMenuStopColor
        {
            get { return this.bhxjrenderer.MainMenuStopColor; }
            set { this.bhxjrenderer.MainMenuStopColor = value; this.Invalidate(); }
        }

        [Description("下拉区域边框颜色"), Category("BHXJ")]
        /// <summary>
        /// 下拉区域边框颜色
        /// </summary>
        public Color DropDownBorder
        {
            get { return this.bhxjrenderer.DropDownBorder; }
            set { this.bhxjrenderer.DropDownBorder = value; this.Invalidate(); }
        }




        /// <summary>
        /// 自定义Renderer
        /// </summary>
        private BHXJToolStripRenderer bhxjrenderer = new BHXJToolStripRenderer();


        public BHXJMenuStrip()
        {
            this.Renderer = bhxjrenderer;

            #region 设计时,变化事件
            if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
            {
                //设计时事件
                this.SizeChanged += new EventHandler(this.BHXJ_SizeChangedInDesignMode);
                this.FontChanged += new EventHandler(this.BHXJ_FontChangedInDesignMode);
                this.LocationChanged += new EventHandler(this.BHXJ_LocationChangedInDesignMode);
            }
            #endregion

            //防止字体在设计器中添加该控件时候自动追随父控件
            this.Font = this.Font;

            //设置初始
            this.IniSize = this.Size;
            this.IniFont = this.Font;
            this.IniLocation = this.BHXJGetIniLocationInDesignMode();

        }

        public BHXJMenuStrip(IContainer container)
        {
            container.Add(this);
            this.Renderer = bhxjrenderer;

            #region 设计时,变化事件
            if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
            {
                //设计时事件
                this.SizeChanged += new EventHandler(this.BHXJ_SizeChangedInDesignMode);
                this.FontChanged += new EventHandler(this.BHXJ_FontChangedInDesignMode);
                this.LocationChanged += new EventHandler(this.BHXJ_LocationChangedInDesignMode);
            }
            #endregion

            //防止字体在设计器中添加该控件时候自动追随父控件
            this.Font = this.Font;

            //设置初始
            this.IniSize = this.Size;
            this.IniFont = this.Font;
            this.IniLocation = this.BHXJGetIniLocationInDesignMode();

        }
    }
}
